//
// Created by sjjmw on 3/24/2022.
//
#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
#include "cmath"
#include<iomanip>
#include "string"

void handle(int k,int n){
    std::vector<int> nums(10000);
    nums[0]=1;
    int num=k;
    int cnt=1;
    while(1){
        int end=cnt;
        nums[cnt]=num;cnt++;
        if(cnt==n){
            break;
        }
        for(int i=0;i<end;i++){
            nums[cnt]=num+nums[i];cnt++;
            if(cnt==n){
                goto end;
            }
        }
        num*=k;
    }
    end:
    printf("%d\n",nums[cnt-1]);
}
int main(){
    int a,b,c;
    while (std::cin>>a){
        handle(a);
    }
    return 0;
}